<!-- 跨断层钻探剖面 -->
<template>
  <el-drawer v-model="addDrawer" size="48%" :show-close="false" @opened="openDrawer" @close="closeDrawer">
    <template #title>
      <el-space direction="vertical" class="space-width100">
        <div v-if="route.path.includes('dataIntegrate') && form.qcOpinion">
          <el-form :model="form" :inline="true" label-width="140px">
            <el-form-item label="质检不通过原因" style="width: 100%">
              <el-input v-model="form.qcOpinion" type="textarea" :autosize="{ minRows: 4, maxRows: 6 }" resize="none"
                clearable></el-input>
            </el-form-item>
          </el-form>
        </div>
        <h2>
          <el-row justify="space-between">
            <span><svg-icon icon-class="list"></svg-icon><span style="padding-left: 15px">{{ typeName }}</span></span>
            <el-button type="primary" @click="confirmClick" :disabled="drawerLoading"
              v-if="isShowSave">保存</el-button>
          </el-row>
        </h2>
      </el-space>
    </template>
    <template #default>
      <el-form :model="form" ref="addRef" :inline="true" :rules="formRules" label-width="160px" v-loading="drawerLoading">
        <el-row justify="space-between">
          <el-form-item label="省">
            <el-input v-model="form.province" clearable disabled></el-input>
          </el-form-item>
          <el-form-item label="市">
            <el-input v-model="form.city" clearable disabled></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="区/县">
            <el-input v-model="form.county" clearable disabled></el-input>
          </el-form-item>
          <el-form-item label="剖面编号" prop="id">
            <el-input v-model="form.id" placeholder="请输入剖面编号" clearable maxlength="17"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="工程编号" prop="projectId">
            <el-input v-model="form.projectId" placeholder="请输入工程编号" clearable maxlength="17"></el-input>
          </el-form-item>
          <el-form-item label="目标断层编号" prop="targetFaultId">
            <el-input v-model="form.targetFaultId" placeholder="请输入目标断层编号" clearable maxlength="17"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="目标断层来源" prop="targetFaultSource">
            <dict-select code="FaultSourceCVD" :value="form.targetFaultSource" @update="updateDict('targetFaultSource', $event)"></dict-select>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="目标断层名称" prop="targetFaultName" style="width: 100%">
            <el-input v-model="form.targetFaultName" placeholder="请输入目标断层名称" :autosize="{ minRows: 2, maxRows: 4 }"
              type="textarea" show-word-limit maxlength="50" clearable></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="剖面名称" prop="name" style="width:100%">
            <el-input v-model="form.name" placeholder="请输入剖面名称" :autosize="{ minRows: 2, maxRows: 4 }"
              type="textarea" show-word-limit maxlength="40" clearable></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="钻探地点" prop="locationName" style="width: 100%">
            <el-input v-model="form.locationName" placeholder="请输入钻探地点" clearable :autosize="{ minRows: 2, maxRows: 4 }"
              type="textarea" show-word-limit maxlength="40" resize="none"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="钻孔数" prop="drillingHoleCount">
            <el-input v-model="form.drillingHoleCount" placeholder="请输入钻孔数" clearable maxlength="4"></el-input>
          </el-form-item>
          <el-form-item label="剖面长度 [米]" prop="length">
            <el-input v-model="form.length" placeholder="请输入剖面长度 [米]" clearable maxlength="8"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="断点数" prop="faultPointCount">
            <el-input v-model="form.faultPointCount" placeholder="请输入断点数" clearable maxlength="4"></el-input>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="钻孔剖面图图像文件编号" prop="holeSectionAiid" style="width:100%">
            <el-space direction="vertical" alignment="flex-start" :size="15" class="upload-space">
              <el-input v-model="form.holeSectionAiid" placeholder="请输入钻孔剖面图图像文件编号" clearable maxlength="20"></el-input>
              <ImageUpload v-model="form.holeSectionAiidName" @uploadImage="uploadSuccess('holeSectionAiid', $event)"
                @delFile="deleteFile('holeSectionAiid', $event)" />
            </el-space>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="钻孔剖面图原始文件" prop="holeSectionArwid" style="width:100%">
            <el-space direction="vertical" alignment="flex-start" :size="15" class="upload-space">
              <el-input v-model="form.holeSectionArwid" placeholder="请输入钻孔剖面图原始文件" clearable maxlength="20"></el-input>
              <FileUpload v-model="form.holeSectionArwidName" @uploadFile="uploadSuccess('holeSectionArwid', $event)"
                @delFile="deleteFile('holeSectionArwid', $event)" />
            </el-space>
          </el-form-item>
        </el-row>
        <el-row justify="space-between">
          <el-form-item label="跨断层钻探描述" prop="commentInfo" style="width:100%">
            <el-input v-model="form.commentInfo" placeholder="请输入跨断层钻探描述" :autosize="{ minRows: 6, maxRows: 12 }"
              type="textarea" show-word-limit maxlength="2147483647" clearable></el-input>
          </el-form-item>
        </el-row>
      </el-form>
    </template>
  </el-drawer>
</template>
<script setup>
import useSpatialData from '@/hooks/useSpatialData'
import { eightDouble, fourInt } from '@/utils/validate'
const { route, addDrawer, drawerLoading, form, typeName, openDrawer, closeDrawer, confirmClick, uploadSuccess, deleteFile, updateDict, isShowSave } = useSpatialData()

const formRules = {
  id: [{ required: true, message: '请填写剖面编号！', trigger: 'blur' }],
  projectId: [{ required: true, message: '请填写工程编号！', trigger: 'blur' }],
  targetFaultId: [{ required: true, message: '请填写目标断层编号！', trigger: 'blur' }],
  targetFaultName: [{ required: true, message: '请填写目标断层名称！', trigger: 'blur' }],
  drillingHoleCount: [{ required: true, message: '请填写钻孔数！', trigger: 'blur' }, fourInt],
  length: [{ required: true, message: '请填写剖面长度 [米]！', trigger: 'blur' }, eightDouble],
  faultPointCount: [{ required: true, message: '请填写断点数！', trigger: 'blur' }, fourInt]
}
</script>
<style scoped></style>